package org.sbbs.admin.mbean.sysuser;

import static jakarta.faces.application.FacesMessage.SEVERITY_WARN;
import jakarta.inject.Named;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.omnifaces.cdi.ViewScoped;
import org.sbbs.admin.dao.SysUserRepo;
import org.sbbs.admin.entity.SysUser;
import org.sbbs.admin.manager.SysUserManager;
import org.sbbs.base.jsf.BaseTableMBean;
import static org.sbbs.base.jsf.BaseTableMBean.addDetailMessage;

/**
 *
 * @author jenkins
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Named("sysUserMB")
//@Component("sysUserMB")
@ViewScoped
//@SessionScoped
public class SysUserMBean extends BaseTableMBean<SysUser, Long, SysUserRepo, SysUserManager> {

    private static final long serialVersionUID = -8170966700137807744L;

    public SysUserMBean(SysUserManager m) {
        super(m);
    }

    @Override
    public SysUser createNewObj() {
        return new SysUser();
    }

    public void showMessage(Object msg) {
        addDetailMessage("fdc", SEVERITY_WARN);
    }

//    public void keyUniqValidate(FacesContext context, UIComponent component, Object value) {
//
//        String key = (String) value;
//        SysUser sp = this.getManager().getByKey(key);
//
//        if (sp != null && !sp.getId().equals(this.getEditObj().getId())) {
//            FacesMessage fms = new FacesMessage(this.getSma().getMessage("sys.parameter.key.uniq"));
//            fms.setSeverity(FacesMessage.SEVERITY_ERROR);
//            throw new ValidatorException(fms);
//        }
//    }
}
